Skip to content

I2C IT mode #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from Nov 7, 2017
Merged

I2C IT mode #135

merged 2 commits into from Nov 7, 2017

Conversation

ghost
Copy link

@ghost ghost commented Oct 17, 2017

Issue #123 fixed.

@ghost ghost self-assigned this Oct 17, 2017
@ghost ghost requested review from fpistm and VVESTM October 17, 2017 12:30
@ghost ghost mentioned this pull request Oct 17, 2017
@fpistm fpistm requested a review from LMESTM October 17, 2017 12:36
Copy link
Member

@LMESTM LMESTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall : Looks good to me !
Only 2 questions raised during review

@@ -101,7 +101,7 @@
*/

/* Family specific description for I2C */
#define I2C_NUM (5)
#define I2C_NUM (4)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this value be defined in the family / target specific files ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be something like this:

#if defined(STM32F7xx) || defined(STM32L4xx)
#define I2C_NUM (4)
#elif defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32L1xx)
#define I2C_NUM (2)
#else // STM32F2xx || STM32F3xx || STM32F4xx || STM32L0xx
#define I2C_NUM (3)
#endif

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

i2c_t *obj = get_i2c_obj(hi2c);

if(obj->isMaster == 0) {
HAL_I2C_EnableListen_IT(hi2c);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you comment or explain this ErrorCallback management ?
If there is an error, shouldn't we report the error to application ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In master mode, the callback is useless because the error is reported to the Arduino API with i2c_master_write() and i2c_master_read().
In slave mode, there is no mechanism in Arduino API to report an error so the error callback forces the slave to listen again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok Good. So please explain this either with comments in the code, or in the commit message, this is useful information that we cannot guess when reading the code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member

@LMESTM LMESTM Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - good - I see it now !

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above in the header of the function.


obj->irq = I2C1_EV_IRQn;
#if !defined(STM32F0xx) && !defined(STM32L0xx)
obj->irqER = I2C1_ER_IRQn;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one new proposal : in every place where I2Cx_ER_IRQn is being used couldn't you use
#if defined (I2C1_ER_IRQn)
obj->irqER = I2C1_ER_IRQn;
#endif
this would be more future proof I think

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I2C1_ER_IRQn is a enum value this could not be done.

#elif defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32L1xx)
#define I2C_NUM (2)
#else // STM32F2xx || STM32F3xx || STM32F4xx || STM32L0xx
#define I2C_NUM (3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you thin about
#elif defined( STM32F2xx) || defined(STM32F3xx) || defined(STM32F4xx) || #defined(STM32L0xx)
#else
#error Unknown Family - unknown I2C_NUM
#endif
so that 3 is not the default for any new family and we will be remonded to complete this part

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

i2c_t *obj = get_i2c_obj(hi2c);

if(obj->isMaster == 0) {
HAL_I2C_EnableListen_IT(hi2c);
Copy link
Member

@LMESTM LMESTM Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - good - I see it now !

Copy link
Contributor

@VVESTM VVESTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
Tested on my side with #135 and #131 . With those 2 PR, my demo, BLE and the NFC are OK.

Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting #131 approval before merge

@fpistm fpistm merged commit 42c5521 into stm32duino:master Nov 7, 2017
@ghost ghost deleted the i2c_master_it_mode branch November 8, 2017 14:37
benwaffle pushed a commit to benwaffle/Arduino_Core_STM32 that referenced this pull request Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants